package com.guaoran.source.mybatis.v2;

import com.guaoran.source.mybatis.bean.Demo;
import com.guaoran.source.mybatis.v2.config.Configuration;
import com.guaoran.source.mybatis.v2.execute.DefaultExecutor;
import com.guaoran.source.mybatis.v2.execute.ExecutorFactory;
import com.guaoran.source.mybatis.v2.mapper.DemoMapper;
import com.guaoran.source.mybatis.v2.plugin.InterceptorChain;
import com.guaoran.source.mybatis.v2.session.SqlSession;
import com.guaoran.source.mybatis.v2.statement.StatementHandler;

import java.util.List;

/**
 * @author : 孤傲然
 * @Description :
 * @date :2018/5/26 13:16
 */
public class ApplicationV2 {
    public static void main(String[] args) throws Exception {
        InterceptorChain interceptorChain = new InterceptorChain();
        Configuration configuration = new Configuration(interceptorChain);
        SqlSession sqlSession =
                new SqlSession(
                        configuration,
                        ExecutorFactory.getExecutor(
                                ExecutorFactory.ExecutorType.CACHE.name(),
                                configuration)
                );
        DemoMapper mapper = sqlSession.getMapper(DemoMapper.class);
        Demo demo = mapper.queryById(2);
        Demo demo2 = mapper.queryById(2);
        System.out.println(demo);
        List<Demo> list = mapper.queryAll();
        for (Demo d:list) {
            System.out.println(d);
        }
    }
}
